<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
          *{
            margin: 0px;
            padding: 0px;
            list-style: none;
        }
        div{
            margin: 0px auto;
            
        }
        #row{
            position: absolute;
            top: 103px;
            left: 180px;
            /* animation: tom 2s linear infinite; */
            
        }
        .we{
            position: relative;
            
        }
        /* @keyframes tom{
            0%{
                transform:rotate(0deg);
            }
            25%{
                transform:rotate(90deg);
            }
            50%{
                transform:rotate(180deg);
            }
            75%{
                transform:rotate(270deg);
            }
            100%{
                transform:rotate(360deg);
            }
        } */
    </style>
</head>
<body>
     <div>
        <img src="images/pic.png" alt="" class="we">
        <img src="images/row.png" alt="" id="row">
    </div>
    <script>
        var row=document.getElementById('row');
        var n=0;
        var timer;
        row.onclick=function(){
            clearInterval(timer);
            n=0;
            row.style.transform=`rotate(${n}deg)`;
            timer=setInterval(function(){
                    var a=parseInt(Math.random()*8)
                    m=360*5+a*45;
                    n=n+45;
                    if(n>=m){
                        console.log(1)
                        clearInterval(timer);
                    }else{
                        row.style.transform=`rotate(${n}deg)`;
                    }                    
                },100) 
            }   
    </script>
</body>
</html>